package com.example.tijian_doctor_backend.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.tijian_doctor_backend.pojo.Overallresult;
import com.example.tijian_doctor_backend.result.Result;
import com.example.tijian_doctor_backend.service.OverallresultService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: bong~
 * @description: TODO
 * @date: 2024/6/24 11:33
 * @version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("/overallResult")
@Api(tags ="总检结论")
@CrossOrigin("*")
public class OverallResultController {

    @Autowired
    private OverallresultService overallresultService;


    @PostMapping("/listOverallResultByOrderId")
    @ApiOperation("查看订单下的总检结论")
    public Result listOverallResultByOrderId(@RequestParam Integer orderId){

//        System.out.println(orderId);

        QueryWrapper<Overallresult> queryWrapper=new QueryWrapper<Overallresult>()
                .eq("orderId",orderId);

        List<Overallresult> list=overallresultService.list(queryWrapper);

        return Result.success(list);

    }

    @PostMapping("/saveOverallResult")
    @ApiOperation("添加总检结论")
    public Result saveOverallResult(@RequestBody Overallresult overallresult){

        System.out.println(overallresult.toString());

        overallresultService.save(overallresult);

        return Result.success();

    }

    @PostMapping("/removeOverallResult")
    @ApiOperation("删除总检结论")
    public Result removeOverallResult(@RequestParam Integer orId){

        overallresultService.removeById(orId);

        return Result.success();
    }


    @PostMapping("/updateOverallResult")
    @ApiOperation("更新总检结论")
    public Result updateOverallResult(@RequestBody Overallresult overallresult){

        overallresultService.updateById(overallresult);

        return Result.success();

    }

}
